/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
 * Description: hvd adapter header file
 * Author: wangcimeng
 * Create: 2020-5-18
 */

#ifndef HVD_ADAPTER_H
#define HVD_ADAPTER_H

#include "hccl/hvd_adapter_pub.h"
#include <thread>
#include <vector>
#include <map>
#include <algorithm>
#include "comm.h"

namespace hccl {
class HvdAdapter {
public:
    HvdAdapter();
    ~HvdAdapter();

    HcclResult HvdAdapterInit(const rtStream_t stream, const s32 deviceID);
    HcclResult HvdAdapterDestroy();
protected:
private:
    bool shutDown_ = false;                                     // 线程关闭标志位
    bool threadInited_ = false;                                 // 线程拉起标志位
    u64 threadId_ = INVALID_U64;                                // 线程Id
    std::vector<rtStream_t> threadStream_;                      // 线程绑定的streams
    std::unique_ptr<std::thread> hvdAdapterThread_;             // 线程对象
    HcclResult HvdAdapterThread(s32 deviceID);                // 线程执行函数，通过init和destroy拉起和关闭
};

extern HvdAdapter g_hvdAdapterGlobal;                           // 全局的HvdAdapter线程管理对象
extern HvdCbDataProcessFunc g_cbDataProcessFunc;                // 保存处理回host侧数据的函数vector
extern void HvdOpCallbackFunc(void *fnData);
}
#endif
